package com.leng.util;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

/**
 * 输出日志工具类
 * @author wangyiyin
 *
 */
public class LoggerUtil {

	/**
	 * 将堆栈异常信息转成字符串
	 * @param t
	 * @return
	 */
	public static String getPrintStackTrace(Throwable t){
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
		PrintStream ps = null;
		try {
			ps = new PrintStream(bos);
			t.printStackTrace(ps);
			ps.flush();
			bos.flush();
			return bos.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}finally {
			if(ps !=null){
				ps.close();
			}
		}
		
		return null;
	}
	
}
